﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace StudyAlgorithm
{
    class KnightTour
    {
        static int N = 8;
        static List<int> cells = new List<int>();
        static int[] indexes = new int[64];
        static bool[] visited = new bool[64];
        static Stack<int> path = new Stack<int>();

        public static void Start()
        {
            Init();
            Try(0);
        }

        public static void Init()
        {
            for (int i = 0; i < N * N; i++)
            {
                cells.Add(i);
                indexes[i] = 0;
                visited[i] = false;
            }
        }

        public static void Try(int begin)
        {

        }
        public static int getNext(int a, int index)
        {
            int X = a / N;
            int Y = a % N;
            switch (index)
            {
                case 0: { if ((X - 2 > -1) && (Y - 1 > -1)) return ((X - 2) * 8 + Y - 1); else return -1;}
                case 1: { if ((X - 1 > -1) && (Y - 2 > -1)) return ((X - 1) * 8 + Y - 2); else return -1;}
                case 2: { if ((X + 2 < 8) && (Y + 1 < 8)) return ((X + 2) * 8 + Y + 1); else return -1;}
                case 3: { if ((X + 1 < 8) && (Y + 2 < 8)) return ((X + 1) * 8 + Y + 2); else return -1;}
                case 4: { if ((X - 2 > -1) && (Y + 1 < 8)) return ((X - 2) * 8 + Y + 1); else return -1;}
                case 5: { if ((X + 1 < 8) && (Y - 2 > -1)) return ((X + 1) * 8 + Y - 2); else return -1;}
                case 6: { if ((X + 2 < 8) && (Y - 1 > -1)) return ((X + 2) * 8 + Y - 1); else return -1;}
                case 7: { if ((X - 1 > -1) && (Y + 2 < 8)) return ((X - 1) * 8 + Y + 2); else return -1;}
            }
            return -1;
        }
    }
}
